<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI书签智能分类</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, sans-serif;
            padding: 20px;
            width: 400px;
            display: flex;
            gap: 16px;
            flex-direction: column;
            align-items: stretch;
            background: #f5f5f7;
            color: #1d1d1f;
        }

        .stats-container {
            background: white;
            border-radius: 12px;
            padding: 16px;
            text-align: center;
            color: #1d1d1f;
            font-size: 14px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .stats-container:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        .stats-number {
            font-weight: 600;
            color: #0066CC;
            font-size: 18px;
            margin: 0 4px;
        }

        .button-group {
            display: flex;
            gap: 12px;
        }

        button {
            flex: 1 1 auto;
            min-width: 120px;
            background: #0066CC;
            color: white;
            border: none;
            padding: 12px;
            border-radius: 12px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 6px rgba(0, 102, 204, 0.2);
        }

        button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
            background: #0077ED;
        }

        button:active {
            transform: translateY(0);
            box-shadow: 0 2px 4px rgba(0, 102, 204, 0.2);
            background: #005CC8;
        }

        .progress-container {
            background: #E5E5E5;
            border-radius: 8px;
            height: 6px;
            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #0066CC, #5E9EFF);
            transition: width 0.3s ease;
        }

        #detailed-progress {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            background: white;
            padding: 16px;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            font-size: 13px;
        }

        #detailed-progress span {
            color: #6e6e73;
        }

        #detailed-progress span span {
            color: #1d1d1f;
            font-weight: 500;
        }

        .tree {
            list-style-type: none;
            padding-left: 0;
            margin: 0;
        }

        .tree li {
            padding: 8px 12px;
            border-radius: 8px;
            transition: all 0.2s ease;
            margin: 4px 0;
        }

        .tree li:hover {
            background: rgba(0, 102, 204, 0.05);
        }

        .folder {
            color: #0066CC;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            padding: 8px;
            border-radius: 8px;
            transition: all 0.2s ease;
        }

        .folder:hover {
            background: rgba(0, 102, 204, 0.05);
        }

        .folder::before {
            content: "▶";
            margin-right: 8px;
            font-size: 10px;
            transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            color: #0066CC;
        }

        .folder.expanded::before {
            transform: rotate(90deg);
        }

        .tree a {
            text-decoration: none;
            color: #1d1d1f;
            transition: color 0.2s ease;
            display: block;
            padding: 6px 8px;
            border-radius: 6px;
        }

        .tree a:hover {
            color: #0066CC;
            background: rgba(0, 102, 204, 0.05);
        }

        #loading {
            display: flex;
            align-items: center;
            gap: 12px;
            color: #6e6e73;
            font-size: 14px;
            padding: 16px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .loading-spinner {
            width: 20px;
            height: 20px;
            border: 2px solid rgba(0, 102, 204, 0.1);
            border-left-color: #0066CC;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div class="stats-container">
        待分类书签：<span id="unclassified-count" class="stats-number">0</span> 个
    </div>
    <div class="button-group">
        <button id="classify" data-tooltip="根据设置使用对应的分类模式">开始分类</button>
        <button id="open_settings" data-tooltip="配置API接入点和分类模式">设置</button>
    </div>

    <div class="progress-container" style="display: none;">
        <div class="progress-bar" style="width: 0%"></div>
    </div>

    <div id="detailed-progress" style="display: none;">
        <span>进度：<span id="processed-count">0/0</span></span>
        <span>总耗时：<span id="total_time">0</span></span>
        <span>Token用量：<span id="live-tokens">0</span></span>
        <span>预估剩余时间：<span id="eta">计算中...</span></span>
    </div>

    <div id="loading">
        <span class="loading-spinner"></span>
        <span class="loading-text">正在准备分类数据...</span>
    </div>

    <div id="error"></div>

    <ul id="output" class="tree"></ul>

    <button id="save_bookmarks" style="display:none;">保存结果</button>
    <script src="popup.js"></script>
</body>

</html>